﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Resources;
using System.Globalization;

namespace LPV_POS.mh_pos.mh_doanhthu
{
    public partial class mh_baocaodoanhthu_diem_KH : Form
    {
        CultureInfo culture;
        #region "Muti language"

        private void SetLanguage_banhang(string cultureName)
        {
            try
            {
                culture = CultureInfo.CreateSpecificCulture(cultureName);
                ResourceManager rm = new ResourceManager("LPV_POS.Muti_language.MyResource", typeof(mh_banhang6_PhuThu).Assembly);
                label1.Text = rm.GetString("diemkhachhang", culture);
                btnTimKiem.Text = rm.GetString("tim", culture);
                btnXuat.Text = rm.GetString("xuatexcel", culture);
                btnThoat.Text = rm.GetString("thoat", culture);
                this.col_STT.Caption = rm.GetString("stt", culture);
                this.col_GHI_CHU.Caption = rm.GetString("khachhang", culture);
                this.COL_SDT.Caption = rm.GetString("dienthoai", culture);
                this.col_SO_LUONG.Caption = rm.GetString("diem", culture);
                label2.Text = rm.GetString("diem", culture);

              
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Note");
            }

        }

        #endregion
        public mh_baocaodoanhthu_diem_KH()
        {
            InitializeComponent();
            culture = CultureInfo.CurrentCulture;
        }

        private void mh_baocaodoanhthu_diem_KH_Load(object sender, EventArgs e)
        {
            cpublic ocpublic = new cpublic();
            string str_lang = ocpublic.Registry_Get("mh_main_lang");
            if (str_lang == "")
                str_lang = "vi-VN";
            SetLanguage_banhang(str_lang);

            decimal idiem = 0;
            decimal.TryParse(new cpublic().Registry_Get(this.Name + "" + nudDiem.Name), out idiem);
            nudDiem.Value = idiem;

        }

        private void btnTimKiem_Click(object sender, EventArgs e)
        {
            thuvien othuvien = new thuvien();
            DataTable tb = othuvien.SP_SelectDataTable("sp_DM_KHACHHANG_DIEM", new string[] { "@DIEM" }, new object[] { nudDiem.Value });
            grdTienPhong.DataSource = tb;
            new cpublic().Registry_Set(this.Name + "" + nudDiem.Name, nudDiem.Value);
        }

        private void btnXuat_Click(object sender, EventArgs e)
        {
            if (grdTienPhong.DataSource != null)
            {
                string sPath = Application.StartupPath + "\\KH_Diem" + DateTime.Now.ToString("") + ".xls";
                DataSet ds = new DataSet();
                ds.Tables.Add(((DataTable)grdTienPhong.DataSource).Copy());
                new cpublic().ExportExcel(ds, sPath);
            }
        }

        private void panel1_Paint(object sender, PaintEventArgs e)
        {

        }
    }
}
